<template>
	<view class="content">
		<view class="tabs">
			<view @click="queryType(0)" class="tabs_item" v-if="recordType !=0"><view >全部</view></view>
			<view @click="queryType(0)" class="tabs_item" v-if="recordType ==0"><view class="on">全部</view></view>
			<view @click="queryType(1)" class="tabs_item" v-if="recordType !=1"><view>待核查</view></view>
			<view @click="queryType(1)" class="tabs_item" v-if="recordType ==1"><view  class="on">待核查</view></view>
			<view @click="queryType(2)" class="tabs_item" v-if="recordType !=2"><view >已核查</view></view>
			<view @click="queryType(2)" class="tabs_item" v-if="recordType ==2"><view class="on">已核查</view></view>
			<view @click="queryType(3)" class="tabs_item" v-if="recordType !=3"><view>已发工资</view></view>
			<view @click="queryType(4)" class="tabs_item" v-if="recordType ==3"><view class="on">已发工资</view></view>
		</view>
		<view class="record-page">
			<scroll-view style="height: 90%;margin-top:5px" scroll-y="true" :refresher-enabled = "refresherEnabled"
				:refresher-triggered="triggered" lower-threshold="50" :refresher-threshold="100"
				refresher-background="lightgreen" @refresherpulling="onPulling">
				<view class="detai-row" v-for="(record) in recordList">
					<view class="row-view">
						<text class="txt-date">{{record.createDate}}</text>
						<text class="txt-stts" v-if="record.recordType==1">待核对</text>
						<text class="txt-stts" v-if="record.recordType==2">已核查</text>
						<text class="txt-stts" v-if="record.recordType==3">已发工资</text>
					</view>
					<view class="record-view">
						<view class="rcord-item">订单号:{{record.id}}</view>
						<view class="rcord-item">客户姓名：{{record.custName}}</view>
						<view class="rcord-item">总金额：{{record.totalAmount}}</view>
						<view class="rcord-item">优惠金额：{{record.discountAmount}}</view>
						<view class="rcord-item">收费金额：现金 {{record.totalCashAmount}} 电子 {{record.totalCardAmount}}</view>
						<view class="rcord-item">小费金额： {{record.tipsCardAmount}} </view>
						<view class="rcord-item">分成比例:{{record.technicianRate}}%</view>
						<view class="rcord-item">分成金额：现金 {{record.techCashAmount}} 电子 {{record.techCardAmount + record.tipsCardAmount }}</view>
						<view class="rcord-item">流水号：{{record.cardRemark}}</view>
						<view class="rcord-item">备注：{{record.recordRemark}}</view>
					</view>
					<view class="record-floor" v-if="record.recordType==1">
						<view class="record-button" @click="edit(record.id)">编辑</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {findRecordPage} from '@/api/record/record'
	export default {
		data() {
			return {
				triggered:false,
				totalPages:0,
				recordList:[],
				recordType:0,
				refresherEnabled:true,
				params:{
					statTime:null,
					endTime:null,
					pageNum:1,
					pageSize:10
				},
			}
		},
		created(){
			
			this.queryPage();
		},
		methods: {
			queryType(recordType){
				this.recordType = recordType;
				this.params.recordType =recordType;
				this.params.timeType =2;
				this.params.pageNum = 1;
				this.recordList=[];
				this.refresherEnabled = true; 
				this.queryPage();
				
			},
			queryPage(){
				findRecordPage(this.params).then(res => {
					if (res.data != undefined && res.data.length > 0) {
						this.totalPages = res.totalPage;
						for (var i = 0; i < res.data.length; i++) {
							this.recordList.push(res.data[i]);
						}
					}
					this.triggered = false;
				})
			},
			onPulling(e) {
				this.triggered = true;
				this.params.pageNum += 1;
				if (this.params.pageNum <= this.totalPages) {
					this.queryPage();
				} else {
					this.refresherEnabled = false;
				}
			},
			edit(id) {
				this.$tab.navigateTo('/pages/record/add?id=' + id);
			},
		}
	}
</script>

<style>
	page {
		background-color: #f5f8fc;
	}

	.content {
		margin: 4px 8px;

	}
	.example-body{
		padding: 4px 0px;
		margin-top: 5px;
	}
	.record-page {
		margin-top: 50px;
	}

	.detai-row {
		background-color: #ffffff;
		display: flex;
		border-radius: 4px;
		flex-wrap: wrap;
		margin-top: 10px;
		padding-bottom: 10px;
	}

	.detai-row .row-view {
		display: flex;
		width: 100%;
		height: 36px;
		align-items: center;
		font-size: 16px;
		padding: 0px 10px 0px 10px;
		border-bottom: 1px solid #f6f6f6;
	}

	.detai-row .row-view .txt-stts {
		display: flex;
		flex: 1;
		justify-content: flex-end;
	}

	.detai-row .record-view {
		width: 100%;
		height: 36px;
		display: inline-table;
		align-items: center;
		font-size: 15px;
	}

	.detai-row .record-view .rcord-item {
		padding: 2px 0;
		margin-left: 5px;
	}

	.detai-row .record-floor {
		display: flex;
		height: 36px;
		align-items: center;
		font-size: 16px;
		padding: 0px 10px 0px 10px;
		border-top: 1px solid #f6f6f6;
		flex: 1;
		justify-content: flex-end;
		align-items: center;
		padding: 10px 0px;
		margin-right: 10px;
	}

	.detai-row .record-floor .record-button {
		padding: 4px 11px;
		border-radius: 23px;
		color: red;
		border: 1px solid red;
	}
	.tabs{
		position: fixed;
		width: 100%;
		height: 40px;
		color: #666;
		font-size: 14px;
		background-color: #fff;
		display: flex;
		z-index: 999;
		top:53px;
	}
	.tabs_item{
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.on{
		margin: 0px 10px 0px 10px;
		padding: 10px 0px 10px 0px;
		color: red;
		font-weight: 700;
		border-bottom: 2px solid red;
	}
</style>
